libostree: Allow compression level to be set for archive-z2 stream
authorPhilip Withnall <withnall@endlessm.com>
Mon, 6 Mar 2017 17:48:36 +0000 (17:48 +0000)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 6 Mar 2017 18:19:45 +0000 (18:19 +0000)
Add a ostree_raw_file_to_archive_z2_stream_with_options() variant of
ostree_raw_file_to_archive_z2_stream(), to allow a compression-level
option to be passed in and passed through to zlib.

This is useful when building archive-z2 files on the fly for
transmission over a non-bandwidth-limited channel, such as a local
network. In this case, CPU time is more valuable than bandwidth, so we
want a low compression level.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #721
Approved by: cgwalters

apidoc/ostree-sections.txt
src/libostree/libostree.sym
src/libostree/ostree-core.c
src/libostree/ostree-core.h

index ed6066042d79a8e36c929833c4eefcb2514ad45e..787664b31e3556c7da965da6177f8856f88f66a4 100644 (file)
@@ -117,6 +117,7 @@ ostree_content_stream_parse
 ostree_content_file_parse
 ostree_content_file_parse_at
 ostree_raw_file_to_archive_z2_stream
+ostree_raw_file_to_archive_z2_stream_with_options
 ostree_raw_file_to_content_stream
 ostree_checksum_file_from_input
 ostree_checksum_file
index a07e5d3b4d6ef4b3136ab3d306fc87e10e3524c7..7c7c3aef03d4fffed5d39df26a857759d1886ed5 100644 (file)
@@ -381,12 +381,10 @@ global:
  *                         NOTE NOTE NOTE
  */
 
-/* Uncomment this when adding the first new symbol for 2
-LIBOSTREE_2017.XX {
+LIBOSTREE_2017.3 {
 global:
-       someostree_symbol_deleteme;
+        ostree_raw_file_to_archive_z2_stream_with_options;
 } LIBOSTREE_2017.2;
-*/
 
 /* Stub section for the stable release *after* this development one; don't
  * edit this other than to update the last number.  This is just a copy/paste
index af36d98b2c9ce0d5131f87aa369c4ecebe91317f..cf238b410ba481848dfd0d6c87b938e034fea00c 100644 (file)
@@ -506,6 +506,46 @@ ostree_raw_file_to_archive_z2_stream (GInputStream       *input,
                                              out_input, cancellable, error);
 }
 
+/**
+ * ostree_raw_file_to_archive_z2_stream_with_options:
+ * @input: File raw content stream
+ * @file_info: A file info
+ * @xattrs: (allow-none): Optional extended attributes
+ * @options: (nullable): A GVariant `a{sv}` with an extensible set of flags
+ * @out_input: (out): Serialized object stream
+ * @cancellable: Cancellable
+ * @error: Error
+ *
+ * Like ostree_raw_file_to_archive_z2_stream(), but supports an extensible set
+ * of flags. The following flags are currently defined:
+ *
+ * - `compression-level` (`i`): Level of compression to use, 0–9, with 0 being
+ *   the least compression, and <0 giving the default level (currently 6).
+ *
+ * Since: 2017.3
+ */
+gboolean
+ostree_raw_file_to_archive_z2_stream_with_options (GInputStream       *input,
+                                                   GFileInfo          *file_info,
+                                                   GVariant           *xattrs,
+                                                   GVariant           *options,
+                                                   GInputStream      **out_input,
+                                                   GCancellable       *cancellable,
+                                                   GError            **error)
+{
+  gint compression_level = -1;
+
+  if (options)
+    (void) g_variant_lookup (options, "compression-level", "i", &compression_level);
+
+  if (compression_level < 0)
+    compression_level = OSTREE_ARCHIVE_DEFAULT_COMPRESSION_LEVEL;
+
+  return _ostree_raw_file_to_archive_stream (input, file_info, xattrs,
+                                             compression_level,
+                                             out_input, cancellable, error);
+}
+
 /**
  * ostree_raw_file_to_content_stream:
  * @input: File raw content stream
index a3419949cf276e1898da56bfb40dbba01427e0e1..bd3d5f2ccea731ae0fdf4ea3b8f1a6526b2fe1e0 100644 (file)
@@ -311,6 +311,16 @@ ostree_raw_file_to_archive_z2_stream (GInputStream       *input,
                                       GCancellable       *cancellable,
                                       GError            **error);
 
+_OSTREE_PUBLIC
+gboolean
+ostree_raw_file_to_archive_z2_stream_with_options (GInputStream       *input,
+                                                   GFileInfo          *file_info,
+                                                   GVariant           *xattrs,
+                                                   GVariant           *options,
+                                                   GInputStream      **out_input,
+                                                   GCancellable       *cancellable,
+                                                   GError            **error);
+
 _OSTREE_PUBLIC
 gboolean ostree_raw_file_to_content_stream (GInputStream       *input,
                                             GFileInfo          *file_info,